<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>预约管理</title>
<link type="text/css" rel="stylesheet" href="css/styleA.css" />
<link type="text/css" rel="stylesheet" href="css/appointmentA.css" />
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="js/jquery.md5A.js"></script>
<script type="text/javascript" src="js/jquery.jsonpA.js"></script>

<script type="text/javascript" src="js/jquery.cookieA.js"></script>
<script type="text/javascript" src="js/pupil-ajaxA.js"></script>
<script type="text/javascript" src="js/bA.js"></script>
<script type="text/javascript" src="js/styleA.js"></script>
</head>
<body>
	<div class="public-top min-cen">
    	<div class="center logo"></div>
        <a href="#">注销</a>
    </div>
    <div class="content center public">
   		<div class="menu">
        	<a class="menu-li" href="javascript:;">
            	<span class="menu-title">个人信息</span>
                <span class="menu-min-title">Personal Information</span>
            </a>
            <a class="menu-li" href="javascript:;">
            	<span class="menu-title">咨询管理</span>
                <span class="menu-min-title">Consulting Management</span>
            </a>
            <a class="menu-li active" href="javascript:;">
            	<span class="menu-title">预约管理</span>
                <span class="menu-min-title">Booking Management</span>
            </a>
            <a class="menu-li" href="javascript:;">
            	<span class="menu-title">收入记录</span>
                <span class="menu-min-title">Income Record</span>
            </a>
            <a class="menu-li" href="javascript:;">
            	<span class="menu-title">提现记录</span>
                <span class="menu-min-title">Present Record</span>
            </a>
        </div>
        <div class="puclic-right">
        	<div class="center-top">
            	<a class="active" href="#">
                	<span class="title">未处理</span>
                	<span class="min-title">Untreated</span>
                </a>
                <a href="./appointment-twoA.html">
                	<span class="title">处理中</span>
                	<span class="min-title">In Treatment</span>
                </a>
                <a href="./appointment-threeA.html">
                	<span class="title">已结束</span>
                	<span class="min-title">Has Ended</span>
                </a>
            </div>
			<!-- 未处理 -->
        	<div class="center-frame" id="appointment_0">
				<div class="appointment-search">
                	<div class="input-box">
                    	<input class="input" name="" type="text" value="" id="searchStr" placeholder="问题描述" />
                        <input class="submit" type="submit"  id = "searchBtn" value="查询" />
                    </div>
                </div>
                <div class="appointment-frame">
                	<div class="appointment-head icon-head">
                		<span class="name">姓名</span>
                        <span class="between">关系</span>
                        <span class="sex">性别/年龄</span>
                        <span class="describe">问题描述</span>
                        <span class="service">服务内容</span>
                        <span class="create-time">生成时间</span>
                        <span class="count">总价
                        	<i class="icon"></i>
                            <span class="prompt">收取平台服务费实际获得金额</span>
                        </span>
                        <span class="reminder">催单
                        	<i class="icon"></i>
                            <span class="prompt">催单会影响用户对您的影响，增加退单率，请您尽快处理。</span>
                        </span>
                        <span class="operation">操作
                        	<i class="icon"></i>
                            <span class="prompt">未联系接单前，用户可以申请退款，请与用户联系预约并确定第一次服务形式和时间。</span>
                        </span>
                	</div>
                    <div class="appointment-body" id="unhandleOrderList" > 
                    </div>
                </div>
                <div class="page">
                    <div class="page-right">
                        <a  id="unhandleOrderListPre" style="display:none;">上一页</a>
                        <a class="active"  id="unhandleOrderListNext" >下一页</a> 
                    </div>
                </div>
            </div>
		</div>
    </div> 
	<!-- 未处理 -->
    <div class="window describe"  style="display:none">
    	<div class="window-bg"></div>
    	<div class="window-frame clear">
        	<div class="window-out">X</div>
        	<div class="title">2016年6月12日08:12:30</div>
        	<div class="text">有人说，失恋是一道逆命题，你一个人做不来，一定要有人成全你，且这个人是你最在乎的人，否则没有杀伤力。单小编认为失恋不过是给自己一个重生的机会，重新认识自己，重新认识世界。</div>
            <span class="out">收回</span>
        </div>
    </div> 
    <div class="alertBox">
        <div class="contact">
            <p class="pname"><span>姓名：</span><b>张文婷</b></p>
            <p class="pgender"><span>性别：</span><b>女</b></p>
            <p class="age"><span>年龄：</span><b>25</b></p>
            <p class="pphone"><span>电话：</span><b>18182923002</b></p>
            <p class="pway">
                <span>咨询方式：</span>
                <select name="askWay" id="askWay">
                    <option value="语音咨询">语音咨询</option>
                    <option value="文字咨询">文字咨询</option>
                    <option value="面对面咨询">面对面咨询</option>
                </select>
            </p>
            <p class="btn"><a href="###" class="cancel">取消</a><a href="###" class="confim">确认</a></p>
        </div>
    </div>
    <style>
        .alertBox{
            display:none;
        }
        .alertBox .contact{
            width:500px;
            height:400px;
            position:absolute;
            margin-left:-250px;
            background-color:#fff;
            top:200px;
            left:50%;
            box-sizing: border-box;
            padding-top:50px;
        }
        .alertBox .contact >p{
            height:30px;
            line-height:30px;
        }
        .alertBox .contact .btn{
            width:40%;
            margin:0 auto;
            margin-top:30px;
        }
        .alertBox .contact .btn >a{
            width:80px;
            height:30px;
            display:block;
            background-color:#17B3E6;
            text-align:center;
            border-radius:6px;
            color:#fff;
        }
        .alertBox .contact .btn >.cancel{
            float:left;
        }
        .alertBox .contact .btn >.confim{
            float:right;
        }
        .alertBox .contact>p>span{
            width:200px;
            float:left;
            text-align:right;
        }
    </style>
	<!-- 已结束 -->
	 <script>
         getCount();//获取数据条数
         function setCount(text,length){
             if(text.length>length){
                 text=text.slice(0,length);
             }
             text+="...";
             return text;
         }
         //详情按钮
         $("#appointment_0").delegate(".describe>a","click",function(event){
             event.preventDefault();
             $(".window .title").html($(this).parent().siblings('.create-time').html());
             $(".window .text").html($(this).attr('description'));
             $(".window").fadeIn();
         })
//         联系弹框关闭按钮
         $(".alertBox .contact .btn >.cancel").click(function(){
             $(".alertBox").fadeOut();
         });
         //        接单按钮
         $("#appointment_0").delegate(".operation>a","click",function(event){
             event.preventDefault();
             $(".alertBox .contact .pname>b").html($(this).parent().siblings(".name").html());
             $(".alertBox .contact .pgender>b").html($(this).parent().siblings(".sex").html().slice(0,1));
             $(".alertBox .contact .age>b").html($(this).parent().siblings(".sex").html().split("/")[1]);
             $(".alertBox .contact .pphone>b").html($(this).attr("contactPhone"));
            var text=$(this).parent().siblings(".service").html().split("*")[0]+"咨询";
             var count=$("#askWay option").length;
             for(var i=0;i<count;i++){
                 if($("#askWay ").get(0).options[i].text == text){
                     $("#askWay ").get(0).options[i].selected = true;
                     break;
                 }
             }
             $("#askWay option[text="+text+"]").attr("selected", true);
             $(".alertBox").fadeIn();
         })
		$(function(){
//            $(".appointment-body").css('width',$(".appointment-head").css('width'));
			getUnhandleOrderList(1,'');
			$("#unhandleOrderListPre").click(function(){
				var page = $(this).attr("value");
				if(page==2){
					$(this).css("display","block");
				}
				$(this).attr("value",parseInt(page)-1);
				getUnhandleOrderList(page,null);
			});
			$("#unhandleOrderListNext").click(function(){
				var page = $(this).attr("value");
				if(page==2){
					$(this).css("display","block");
				}
				$(this).attr("value",parseInt(page)+1);
				getUnhandleOrderList(page,null);
			});
			
			$("#searchBtn").click(function(){
				var searchStr = $("#searchStr").val();
			});

		});
		
		//获取未接单预约咨询订单
		function getUnhandleOrderList(page,desc){
			var expertId = $.cookie("expertId");
			ajaxPostJson(requestUrl + "/corder/getUnhandleOrderListA", function(data, status){
				eval("rt=" + data);
				if (rt.error!="") {
					$("#unhandleOrderListNext").css("display","none");
					alert(rt.error);
				}else{ 
					var orderList =  rt.orderList; 
					var htmlStr ="";
					if(typeof(orderList)!="undefined"){
						$.each(orderList,function(order){
						    var list=orderList[order];
						htmlStr+= "<div class=\"appointment-li\"> "
								+"<span class=\"name\">"+list.name+"</span>"
								+"<span class=\"between\">本人</span>"
								+"<span class=\"sex\">"+list.gender+"/"+list.age+"</span>"
								+"<span class=\"describe\">"
                                +"<span>"+setCount(list.description,25)+"</span>"
                                +"<a href=\"#\" description=\""+list.description+"\" >详情</a></span>"
								+"<span class=\"service\">"+(list.textTotalNum>0?"文字*"+list.textTotalNum:"")+(list.callTotalNum>0?"<br/>语音*"+list.callTotalNum:"")+(list.f2fTotalNum>0?"<br/>面对面*"+list.f2fTotalNum:"")+"</span>"
								+"<span class=\"create-time\">"+(list.addTime.slice(0,-2))+"</span>"
								+"<span class=\"count\">￥"+list.afterFeeMoney+"</span>"
								+"<span class=\"reminder\">"+list.urgeNum+"</span>"
								+"<span class=\"operation\"><a href=\"javascript:;\" orderId=\""+list.orderId+"\" consultId=\""+list.consultId+"\" contactPhone=\""+list.contactPhone+"\">联系</a></span>"
								+"</div>";
						}); 
						 
					}
					$("#unhandleOrderList").html(htmlStr);
				}
			}, {"from":"expert","currentpage":page,"desc":$("#searchStr").val(),"expertId":expertId,"debug":1});
		}
        //获取consultId
        function getConsultId(){
            return 6604;
        }
//        查询接口
         $("#searchBtn").click(function(){
                var page=1;
             var expertId = $.cookie("expertId");
             ajaxPostJson(requestUrl + "/corder/getUnhandleOrderListA", function(data, status){
                 eval("rt=" + data);
                 if (rt.error!="") {
                     $("#unhandleOrderListNext").css("display","none");
                     alert(rt.error);
                 }else {
                     var orderList = rt.orderList;
                     var htmlStr = "";
                     if (typeof(orderList) != "undefined") {
                         $.each(orderList, function (order) {
                             var list = orderList[order];
                             htmlStr += "<div class=\"appointment-li\"> "
                                     + "<span class=\"name\">" + list.name + "</span>"
                                     + "<span class=\"between\">本人</span>"
                                     + "<span class=\"sex\">" + list.gender + "/" + list.age + "</span>"
                                     + "<span class=\"describe\">"
                                     + "<span>" + setCount(list.description, 25) + "</span>"
                                     + "<a href=\"#\" description=\"" + list.description + "\" >详情</a></span>"
                                     + "<span class=\"service\">文字*" + list.textTotalNum + "<br/>语音*" + list.callTotalNum + "<br/>面对面*" + list.f2fTotalNum + "</span>"
                                     + "<span class=\"create-time\">" + (list.addTime.slice(0, -2)) + "</span>"
                                     + "<span class=\"count\">￥" + list.originMoney + "</span>"
                                     + "<span class=\"reminder\">" + list.urgeNum + "</span>"
                                     + "<span class=\"operation\"><a href=\"javascript:;\" orderId=\"" + list.orderId + "\" consultId=\"" + list.consultId + "\">联系</a></span>"
                                     + "</div>";
                         });
                     }
                 }
                  $("#unhandleOrderList").html(htmlStr);
             },{"from":"expert","currentpage":page,"desc":$("#searchStr").val(),"expertId":expertId,"debug":1});

         })
         setInterval(function(){
             getCount()
         },10000);
         function getCount(){
             var expertId = $.cookie("expertId");
             ajaxPostJson(requestUrl + "/corder//getNumOrderByStatusX", function(data, status){
                 eval("rt=" + data);
                 if (rt.error!="") {
                     $("#unhandleOrderListNext").css("display","none");
                     alert(rt.error);
                 }else {
                     var list=rt.numMap;
                     $(".center-top").find('a').eq(0).find('span').eq(0).html("未处理"+(list.num1>0?"（"+list.num1+"）":''));
                     $(".center-top").find('a').eq(1).find('span').eq(0).html("处理中"+(list.num2>0?"（"+list.num2+"）":''));
                     $(".center-top").find('a').eq(2).find('span').eq(0).html("已结束"+(list.num3>0?"（"+list.num3+"）":''));
                 }
             },{"from":"expert","expertId":expertId,"debug":1})
         }
	</script> 
</body>
</html>
